<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>opacity与图层 GPU 加速</title>
    <style>
        .box {
            width: 200px;
            height: 200px;
            background: linear-gradient(45deg, #ff6b6b, #4ecdc4);
            border: 10px solid #555;
            border-radius: 20px;
            /* GPU加速 */
            transform: translateZ(0);
            will-change: opacity;
            transition: opacity 1s ease-in-out;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 18px;
            color: white;
        }
        .box.hidden {
            opacity: 0;
        }
    </style>
</head>
<body>
    <div id="myBox" class="box">点击我隐藏</div>
    <script>
        const box = document.getElementById('myBox');
        box.addEventListener('click', function() {
            box.classList.toggle('hidden');
            box.textContent = box.classList.contains('hidden') ? '点击我显示' : '点击我隐藏';
        })
    </script>
</body>
</html>